package com.aiyige.page.coupon.model;

import android.os.Parcel;
import android.os.Parcelable;

public class Coupon implements Parcelable {
    String id;
    String couponName;
    String couponType;
    Long useableStartTime;
    Long useableEndTime;
    Double couponAmount;
    Double fullAmount;
    Integer personLimit;
    Long numberOfVoucher;
    String scope;
    String status;
    String scopeDesc;

    public Coupon() {
    }

    public Coupon(Coupon other) {
        this.id = other.id == null ? "" : other.id;
        this.couponName = other.couponName == null ? "" : other.couponName;
        this.couponType = other.couponType == null ? "" : other.couponType;
        this.useableStartTime = other.useableStartTime == null ? 0 : other.useableStartTime;
        this.useableEndTime = other.useableEndTime == null ? 0 : other.useableEndTime;
        this.couponAmount = other.couponAmount == null ? 0 : other.couponAmount;
        this.fullAmount = other.fullAmount == null ? 0 : other.fullAmount;
        this.personLimit = other.personLimit == null ? 0 : other.personLimit;
        this.numberOfVoucher = other.numberOfVoucher == null ? 0 : other.numberOfVoucher;
        this.scope = other.scope == null ? "" : other.scope;
        this.status = other.status == null ? "" : other.status;
        this.scopeDesc = other.scopeDesc == null ? "" : other.scopeDesc;
    }

    private Coupon(Builder builder) {
        setId(builder.id);
        setCouponName(builder.couponName);
        setCouponType(builder.couponType);
        setUseableStartTime(builder.useableStartTime);
        setUseableEndTime(builder.useableEndTime);
        setCouponAmount(builder.couponAmount);
        setFullAmount(builder.fullAmount);
        setPersonLimit(builder.personLimit);
        setNumberOfVoucher(builder.numberOfVoucher);
        setScope(builder.scope);
        setStatus(builder.status);
        setScopeDesc(builder.scopeDesc);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCouponName() {
        return couponName;
    }

    public void setCouponName(String couponName) {
        this.couponName = couponName;
    }

    public String getCouponType() {
        return couponType;
    }

    public void setCouponType(String couponType) {
        this.couponType = couponType;
    }

    public Long getUseableStartTime() {
        return useableStartTime;
    }

    public void setUseableStartTime(Long useableStartTime) {
        this.useableStartTime = useableStartTime;
    }

    public Long getUseableEndTime() {
        return useableEndTime;
    }

    public void setUseableEndTime(Long useableEndTime) {
        this.useableEndTime = useableEndTime;
    }

    public Double getCouponAmount() {
        return couponAmount;
    }

    public void setCouponAmount(Double couponAmount) {
        this.couponAmount = couponAmount;
    }

    public Double getFullAmount() {
        return fullAmount;
    }

    public void setFullAmount(Double fullAmount) {
        this.fullAmount = fullAmount;
    }

    public Integer getPersonLimit() {
        return personLimit;
    }

    public void setPersonLimit(Integer personLimit) {
        this.personLimit = personLimit;
    }

    public Long getNumberOfVoucher() {
        return numberOfVoucher;
    }

    public void setNumberOfVoucher(Long numberOfVoucher) {
        this.numberOfVoucher = numberOfVoucher;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getScopeDesc() {
        return scopeDesc;
    }

    public void setScopeDesc(String scopeDesc) {
        this.scopeDesc = scopeDesc;
    }

    public static final class Builder {
        private String id;
        private String couponName;
        private String couponType;
        private Long useableStartTime;
        private Long useableEndTime;
        private Double couponAmount;
        private Double fullAmount;
        private Integer personLimit;
        private Long numberOfVoucher;
        private String scope;
        private String status;
        private String scopeDesc;

        private Builder() {
            id = "";
            couponName = "";
            couponType = "";
            useableStartTime = 0L;
            useableEndTime = 0L;
            couponAmount = 0D;
            fullAmount = 0D;
            personLimit = 0;
            numberOfVoucher = 0L;
            scope = "";
            status = "";
            scopeDesc = "";
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder couponName(String val) {
            couponName = val;
            return this;
        }

        public Builder couponType(String val) {
            couponType = val;
            return this;
        }

        public Builder useableStartTime(Long val) {
            useableStartTime = val;
            return this;
        }

        public Builder useableEndTime(Long val) {
            useableEndTime = val;
            return this;
        }

        public Builder couponAmount(Double val) {
            couponAmount = val;
            return this;
        }

        public Builder fullAmount(Double val) {
            fullAmount = val;
            return this;
        }

        public Builder personLimit(Integer val) {
            personLimit = val;
            return this;
        }

        public Builder numberOfVoucher(Long val) {
            numberOfVoucher = val;
            return this;
        }

        public Builder scope(String val) {
            scope = val;
            return this;
        }

        public Builder status(String val) {
            status = val;
            return this;
        }

        public Builder scopeDesc(String val) {
            scopeDesc = val;
            return this;
        }

        public Coupon build() {
            return new Coupon(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.couponName);
        dest.writeString(this.couponType);
        dest.writeValue(this.useableStartTime);
        dest.writeValue(this.useableEndTime);
        dest.writeValue(this.couponAmount);
        dest.writeValue(this.fullAmount);
        dest.writeValue(this.personLimit);
        dest.writeValue(this.numberOfVoucher);
        dest.writeString(this.scope);
        dest.writeString(this.status);
        dest.writeString(this.scopeDesc);
    }

    protected Coupon(Parcel in) {
        this.id = in.readString();
        this.couponName = in.readString();
        this.couponType = in.readString();
        this.useableStartTime = (Long) in.readValue(Long.class.getClassLoader());
        this.useableEndTime = (Long) in.readValue(Long.class.getClassLoader());
        this.couponAmount = (Double) in.readValue(Double.class.getClassLoader());
        this.fullAmount = (Double) in.readValue(Double.class.getClassLoader());
        this.personLimit = (Integer) in.readValue(Integer.class.getClassLoader());
        this.numberOfVoucher = (Long) in.readValue(Long.class.getClassLoader());
        this.scope = in.readString();
        this.status = in.readString();
        this.scopeDesc = in.readString();
    }

    public static final Creator<Coupon> CREATOR = new Creator<Coupon>() {
        @Override
        public Coupon createFromParcel(Parcel source) {
            return new Coupon(source);
        }

        @Override
        public Coupon[] newArray(int size) {
            return new Coupon[size];
        }
    };
}
